import intercampi.acess.Requestmap
import intercampi.acess.Role
import intercampi.acess.SecUser
import intercampi.acess.SecUserRole


class BootStrap {
	
	def springSecurityService
	
	def init = { 
		servletContext ->
		String password = springSecurityService.encodePassword('123')
		
		def userAdmin = new SecUser(username: 'admin', enabled: true,password: password).save()
		def adminRole = new Role(authority: 'ROLE_ADMIN').save()
		SecUserRole.create userAdmin, adminRole, true 
		new Requestmap(url: '/js/**', configAttribute:'IS_AUTHENTICATED_ANONYMOUSLY').save()
		new Requestmap(url: '/css/**', configAttribute:'IS_AUTHENTICATED_ANONYMOUSLY').save()
		new Requestmap(url: '/images/**', configAttribute:'IS_AUTHENTICATED_ANONYMOUSLY').save()
		new Requestmap(url: '/login/**', configAttribute:'IS_AUTHENTICATED_ANONYMOUSLY').save()
		new Requestmap(url: '/logout/**', configAttribute:'IS_AUTHENTICATED_ANONYMOUSLY').save()
		new Requestmap(url: '/**', configAttribute: 'ROLE_ADMIN').save()
	}
	
	def destroy = { }
	
}
